// DlgSelect2.cpp : implementation file
//

#include "stdafx.h"
#include "OpenCVView.h"
#include "DlgSelect2.h"
#include "afxdialogex.h"


// CDlgSelect2 dialog

IMPLEMENT_DYNAMIC(CDlgSelect2, CDialog)

CDlgSelect2::CDlgSelect2(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgSelect2::IDD, pParent)
{
	m_Min1 = 0;
	m_Max1 = 255;
	m_Cur1 = 0;
	m_Min2 = 0;
	m_Max2 = 255;
	m_Cur2 = 0;
	m_stcselect1 = 0;
	m_stcselect2 = 0;
}

CDlgSelect2::~CDlgSelect2()
{
}

void CDlgSelect2::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_SLIDER_SELECT1, m_sliderselect1);
	DDX_Text(pDX, IDC_STC_SELECT1, m_stcselect1);
	DDX_Control(pDX, IDC_SLIDER_SELECT2, m_sliderselect2);
	DDX_Text(pDX, IDC_STC_SELECT2, m_stcselect2);
}


BEGIN_MESSAGE_MAP(CDlgSelect2, CDialog)
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_SELECT1, &CDlgSelect2::OnNMCustomdrawSliderSelect1)
	ON_BN_CLICKED(IDOK, &CDlgSelect2::OnBnClickedOk)
	ON_BN_CLICKED(IDCANCEL, &CDlgSelect2::OnBnClickedCancel)
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_SELECT2, &CDlgSelect2::OnCustomdrawSliderSelect2)
END_MESSAGE_MAP()


// CDlgSelect2 message handlers

void CDlgSelect2::OnNMCustomdrawSliderSelect1(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_stcselect1 = m_sliderselect1.GetPos();
	UpdateData(FALSE); 
	*pResult = 0;
}


void CDlgSelect2::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CDialog::OnOK();
}


void CDlgSelect2::OnBnClickedCancel()
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}


// SetSliderRang
void CDlgSelect2::SetSliderRang(int min1, int max1,int cur1,int min2, int max2,int cur2)
{
	m_Min1 = min1;
	m_Max1 = max1;
	m_Cur1 = cur1;
	m_Min2 = min2;
	m_Max2 = max2;
	m_Cur2 = cur2;
}


// GetSelectNum
int CDlgSelect2::GetSelectNum1(void)
{
	return m_stcselect1;
}
int CDlgSelect2::GetSelectNum2(void)
{
	return m_stcselect2;
}


BOOL CDlgSelect2::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	m_sliderselect1.SetRange(m_Min1, m_Max1);
	m_sliderselect1.SetTicFreq((m_Max1-m_Min1)/20);
	m_sliderselect1.SetPos(m_Cur1);
	m_sliderselect2.SetRange(m_Min2, m_Max2);
	m_sliderselect2.SetTicFreq((m_Max2-m_Min2)/20);
	m_sliderselect2.SetPos(m_Cur2);


	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}


//BOOL CDlgSelect1::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
//{
//	// TODO: Add your specialized code here and/or call the base class
//
//	return CDialog::Create(lpszTemplateName, pParentWnd);
//}


void CDlgSelect2::OnCustomdrawSliderSelect2(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
	// TODO: Add your control notification handler code here
	m_stcselect2 = m_sliderselect2.GetPos();
	UpdateData(FALSE); 
	*pResult = 0;
}
